]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
messageTray: Only connect to a notification's open/destroy once
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 14 Oct 2013 01:51:30 +0000 (21:51 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 14 Oct 2013 19:24:53 +0000 (15:24 -0400)
If we pushNotification the same notification multiple times, we
won't append it to the array again, but we will attach multiple
handlers needlessly.

https://bugzilla.gnome.org/show_bug.cgi?id=710115

js/ui/messageTray.js

index 65ab89be16a0031c5cd2b3ef7f1423e741beb543..9dfb54cec736c6383b89804b574fe8376bfde38a 100644 (file)
@@ -1407,10 +1407,8 @@ const Source = new Lang.Class({
     },
 
     pushNotification: function(notification) {
-        if (this.notifications.indexOf(notification) < 0) {
-            this.notifications.push(notification);
-            this.emit('notification-added', notification);
-        }
+        if (this.notifications.indexOf(notification) >= 0)
+            return;
 
         notification.connect('clicked', Lang.bind(this, this.open));
         notification.connect('destroy', Lang.bind(this,
@@ -1426,6 +1424,9 @@ const Source = new Lang.Class({
                 this.countUpdated();
             }));
 
+        this.notifications.push(notification);
+        this.emit('notification-added', notification);
+
         this.countUpdated();
     },